import 'package:flutter/material.dart';

/// 加载进度条组件
class LoadingContainer extends StatelessWidget {
  final Widget child;
  final bool isLoading;
  final bool cover;

  const LoadingContainer(
      {super.key,
      required this.child,
      required this.isLoading,
      this.cover = false});

  @override
  Widget build(BuildContext context) {
    if (!cover) {
      return !isLoading
            ? child
            : _loadingView;
    } else {
      return Stack(
            children: <Widget>[child, isLoading ? _loadingView : Container()],
          );
    }
  }

  Widget get _loadingView {
    return const Center(
      child: CircularProgressIndicator(),
    );
  }
}
